import 'package:flutter/material.dart';
import 'app/image.dart';
import 'app/net.dart';
import 'app/myanin.dart';
import 'test/test01.dart';
import 'test/test02.dart';
void main() => runApp(new MyTest());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomw(),
      onGenerateRoute: (RouteSettings sets){
        switch(sets.name){
          case '/image':
            return new MyCustomRoute(
              builder: (_) => new MyImage(),
              settings: sets,
            );
          case '/net':
          return new MyCustomRoute(
            builder: (_) => new MyGetNet(),
            settings: sets,
          );
          case '/anim':
            return new MyCustomRoute(
              builder: (_) => new MyAnintPage(),
              settings: sets,
            );
        }
      },
    );
  }
}



class MyCustomRoute<T> extends MaterialPageRoute<T> {
  MyCustomRoute({WidgetBuilder builder, RouteSettings settings})
      : super(builder: builder, settings: settings);

  @override
  Widget buildTransitions(BuildContext context, Animation<double> animation,
      Animation<double> secondaryAnimation, Widget child) {
    if (settings.isInitialRoute) return child;
    return new FadeTransition(opacity: animation, child: child);
  }
}


class MyHomw extends StatefulWidget{

  @override
  State<MyHomw> createState() {
    // TODO: implement createState
    return new MyHomwState();
  }

}

class MyHomwState extends State<MyHomw>{

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
      appBar: new AppBar(
        title: new Text("标题"),
      ),
      body: new ListView(
        children: <Widget>[
          new MaterialButton(onPressed:(){
            Navigator.pushNamed(context, "/image");
          },
          child: new Container(
            height: 50.0,
            child: new Row(
              mainAxisAlignment: MainAxisAlignment.start,
              mainAxisSize: MainAxisSize.max,
              children: <Widget>[
                new Text("图片空间"),
              ],
            ),
          ),
          ),
          new MaterialButton(onPressed: (){
            Navigator.pushNamed(context, "/net");
          },
            child: new Container(
              height: 50.0,
              child: new Row(
                mainAxisAlignment: MainAxisAlignment.start,
                mainAxisSize: MainAxisSize.max,
                children: <Widget>[
                  new Text("基本ui操作"),
                ],
              ),
            ),
          ),
          new MaterialButton(onPressed: (){
            Navigator.pushNamed(context, "/anim");
          },
            child: new Container(
              height: 50.0,
              child: new Row(
                mainAxisAlignment: MainAxisAlignment.start,
                mainAxisSize: MainAxisSize.max,
                children: <Widget>[
                  new Text("动画"),
                ],
              ),
            ),
          )
        ],
      ),
    );
  }
}